package com.leyou.auth.inter.util;

import lombok.Getter;

/**
 * @author zqq
 * @ClassName TokenState
 * @Description
 * @date 2020/3/27-14:16
 */
@Getter
public enum TokenState {

    EXPIRED("EXPIRED"), //token过期
    SIGNATURE("SIGNATURE"), //token签名异常
    ANALYSIS_EXCEPTION("ANALYSIS"), //解析异常
    ISS_EXCEPTION("ISS"), //签发者异常
    VALID("VALID");  //有效的token


    private String state;

    TokenState(String state) {
        this.state = state;
    }

    /**
     * 根据状态字符串获取token状态枚举对象
     */
    public static TokenState getTokenState(String tokenState) {
        TokenState[] states = TokenState.values();
        TokenState ts = null;
        for (TokenState state : states) {
            if (state.toString().equals(tokenState)) {
                ts = state;
                break;
            }
        }
        return ts;
    }

    public static void main(String[] args) {
        System.out.println(TokenState.VALID.getState());
    }
}
